<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<title>API tester</title>
		<link rel="stylesheet" type="text/css" href="css/main.css"/>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
	</head>
	
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
	
	<body>

	<div style="width: 100%;">
		<div class="topLine">
			<div style="float: right;"><a href="{{ url }}">{{ url_linktext }}</a> {{user.nickname}}</div>
		</div>
	</div>
	

<div style="clear: both;"/>	

<h1>API tester</h1>

<div style="background: #ccffcc; padding: 10px; border: 2px solid #00ff00">
<p>Hello! :-)</p>

<p>Before you try to call API, you must write your user name. Forgotten your user name? Try "jirka" :)</p>

<p><strong>login: </strong><input type="text" name="login" id="login" size="80"/></p>
</div>
<hr />
<hr />

<h2>Create user</h2>

<p>You can use without logging in.</p>

<p>URL: /api/users/create/</p>
<form action="/api/users/create/" method="post">
	<table>
		<tr>
			<td><label for="nick">nick</label></td>
			<td><input type="text" name="nick" id="nick" size="80"/> <strong>required</strong></td>
		</tr>
		<tr>
			<td><label for="password">password</label></td>
			<td><input type="text" name="password" id="password" size="80"/> <strong>required</strong></td>
		</tr>
		<tr>
			<td><label for="fullname">fullname</label> </td>
			<td><input type="text" name="fullname" id="fullname" size="80"/> <strong>required</strong></td>
		</tr>
		
		<tr>
			<td valign="top"><label for="description">description</label></td>
			<td><textarea rows="4" cols="80" name="description" id="description"></textarea></td>
		</tr>

		<tr>
			<td> </td>
			<td><input type="submit" value="SEND request"/></td>
		</tr>
	</table>
</form>

<div class="result" style="border: 2px solid blue"></div>

<hr />

<h2>Get users</h2>

<p>You can use without logging in.</p>

<p>URL: /api/users/</p>
<form action="/api/users/" method="post">
	<input type="submit" value="SEND request"/>
</form>

<div class="result" style="border: 2px solid blue"></div>


<hr />
<hr />

<h2>Create groups</h2>

<p>Create group and set current user as "manager" this group. Item "data" in the returned JSON contains information about the group you just created.</p>

<p>URL: /api/group/create/</p>
<form action="/api/group/create/" method="post">
	<table>
		<tr>
			<td><label for="name">name</label></td>
			<td><input type="text" name="name" id="name" size="80"/> <strong>required</strong></td>
		</tr>
		
		<tr>
			<td valign="top"><label for="description">description</label></td>
			<td><textarea rows="4" cols="80" name="description" id="description"></textarea><strong>required</strong></td>
		</tr>
		
		<tr>
			<td><label for="deadline">deadline</label></td>
			<td><input type="text" name="deadline" id="deadline" size="80"/></td>
		</tr>
		
				<tr>
			<td><label for="github">github</label></td>
			<td><input type="text" name="github" id="github" size="80"/></td>
		</tr>

		<tr>
			<td> </td>
			<td><input type="submit" value="SEND request"/></td>
		</tr>
	</table>
</form>

<div class="result" style="border: 2px solid blue"></div>

<hr />

<h2>Get groups</h2>
<p>Returns all groups to which the current user belongs. (including groups in which the user sent a request to join)</p>
<p>URL: /api/groups/</p>
<form action="/api/groups/" method="post">
	<input type="submit" value="SEND request"/>
</form>

<div class="result" style="border: 2px solid blue"></div>


<hr />

<h2>Delete group</h2>

<p>Note: Current user must be a group manager!!!</p>
<p>Note: POST parameter to delete the group is "key", not "name"!</p>
<p>URL: /api/group/delete/</p>
<form action="/api/group/delete/" method="post">
	<table>
		<tr>
			<td><label for="key">key</label></td>
			<td><input type="text" name="key" id="key" size="80"/> <strong>required</strong></td>
		</tr>
	<tr><td></td><td><input type="submit" value="SEND request"/></td></tr>
	</table>
</form>

<div class="result" style="border: 2px solid blue"></div>


<hr />


<h2>Join to group</h2>

<p>Note: POST parameter to delete the group is "name", not "key"!</p>

<p>URL: /api/group/join/</p>
<form action="/api/group/join/" method="post">
	<table>
		<tr>
			<td><label for="name">name</label></td>
			<td><input type="text" name="name" id="name" size="80"/> <strong>required</strong></td>
		</tr>
	<tr><td></td><td><input type="submit" value="SEND request"/></td></tr>
	</table>
</form>

<div class="result" style="border: 2px solid blue"></div>


<hr />

<h2>Accept user</h2>

<p>URL: /api/group/acceptuser/</p>
<form action="/api/group/acceptuser/" method="post">
	<table>
		<tr>
			<td><label for="key">key</label></td>
			<td><input type="text" name="key" id="key" size="80"/> (group key) <strong>required</strong></td>
		</tr>
		<tr>
			<td><label for="nick">nick</label></td>
			<td><input type="text" name="nick" id="name" size="80"/> (user nick) <strong>required</strong></td>
		</tr>
	<tr><td></td><td><input type="submit" value="SEND request"/></td></tr>
	</table>
</form>

<div class="result" style="border: 2px solid blue"></div>


<hr />

<h2>Groups's users</h2>

<p>Note: Current user must be a member of group!</p>
<p>Note: POST parameter is "key", not "name"!</p>
<p>URL: /api/group/users/</p>
<form action="/api/group/users/" method="post">
	<table>
		<tr>
			<td><label for="key">key</label></td>
			<td><input type="text" name="key" id="key" size="80"/> <strong>required</strong></td>
		</tr>
	<tr><td></td><td><input type="submit" value="SEND request"/></td></tr>
	</table>
</form>

<div class="result" style="border: 2px solid blue"></div>


<hr />
<hr />
<hr />
<hr />


<h2>Create task</h2>

<p>URL: /api/task/create/</p>
<form action="/api/task/create/" method="post">
	<table>
		<tr>
			<td><label for="name">name</label></td>
			<td><input type="text" name="name" id="name" size="80"/> <strong>required</strong></td>
		</tr>
		<tr>
			<td valign="top"><label for="description">description</label></td>
			<td><textarea rows="4" cols="80" name="description" id="description"></textarea></td>
		</tr>

		<tr>
			<td><label for="deadline">deadline</label></td>
			<td><input type="text" name="deadline" id="deadline" size="80"/> <strong>required</strong></td>
		</tr>
		
		<tr>
			<td><label for="group_key">group_key</label></td>
			<td><input type="text" name="group_key" id="group_key" size="80"/> <strong>required</strong></td>
		</tr>
		
		<tr>
			<td><label for="checked">checked</label></td>
			<td><input type="text" name="checked" id="checked" size="80"/> (True = True, Other values = False)</td>
		</tr>
		
		<tr>
			<td><label for="nick">nick</label></td>
			<td><input type="text" name="nick" id="nick" size="80"/> <strong>required</strong></td>
		</tr>
		
		<tr>
			<td><label for="parent">parent</label></td>
			<td><input type="text" name="parent" id="parent" size="80"/> (Key of parent task, may be empty)</td>
		</tr>
		
		
		<tr>
			<td> </td>
			<td><input type="submit" value="SEND request"/></td>
		</tr>
	</table>
</form>

<div class="result" style="border: 2px solid blue"></div>


<hr />

<h2>Get tasks</h2>

<p>URL: /api/tasks/</p>
<form action="/api/tasks/" method="post">
	<table>
		<tr>
			<td><label for="group_key">group_key</label></td>
			<td><input type="text" name="group_key" id="group_key" size="80"/> <strong>required</strong></td>
		</tr>
		<tr>
			<td></td>
			<td><input type="submit" value="SEND request"/></td>
		</tr>
		</table>
		
	
</form>


<div class="result" style="border: 2px solid blue"></div>


<hr />

<h2>Task - set checked</h2>

<p>URL: /api/task/set_checked/</p>
<form action="/api/task/set_checked/" method="post">
	<table>
		
		<tr>
			<td><label for="task_key">task_key</label></td>
			<td><input type="text" name="task_key" id="task_key" size="80"/> <strong>required</strong></td>
		</tr>
		
		<tr>
			<td><label for="checked">checked</label></td>
			<td><input type="text" name="checked" id="checked" size="80"/> (True = True, Other values = False)</td>
		</tr>
		
		
		<tr>
			<td> </td>
			<td><input type="submit" value="SEND request"/></td>
		</tr>
	</table>
</form>

<div class="result" style="border: 2px solid blue"></div>


<hr />

<hr />

<hr />
<hr />
<hr />
<hr />


<h2>Create message</h2>

<p>URL: /api/message/create/</p>
<form action="/api/message/create/" method="post">
	<table>
		<tr>
			<td><label for="title">title</label></td>
			<td><input type="text" name="title" id="title" size="80"/> <strong>required</strong></td>
		</tr>
		<tr>
			<td valign="top"><label for="text">text</label></td>
			<td><textarea rows="4" cols="80" name="text" id="text"></textarea></td>
		</tr>

		
		<tr>
			<td><label for="group_key">group_key</label></td>
			<td><input type="text" name="group_key" id="group_key" size="80"/> <strong>required</strong></td>
		</tr>
		
		
		
		<tr>
			<td> </td>
			<td><input type="submit" value="SEND request"/></td>
		</tr>
	</table>
</form>

<div class="result" style="border: 2px solid blue"></div>


<hr />

<h2>Get messages</h2>

<p>URL: /api/messages/</p>
<form action="/api/messages/" method="post">
	<table>
		<tr>
			<td><label for="group_key">group_key</label></td>
			<td><input type="text" name="group_key" id="group_key" size="80"/> <strong>required</strong></td>
		</tr>
		<tr>
			<td></td>
			<td><input type="submit" value="SEND request"/></td>
		</tr>
		</table>
		
	
</form>


<div class="result" style="border: 2px solid blue"></div>


<hr />


<script type="text/javascript">

function sendRequest(form_id){
	
	var dataString = 'login='+ $("input[name=login]").val();
	
	var form = $("form#"+form_id);
	var url = form.attr("action");
	
	alert(url);
	
}


$(document).ready(function(){
	 //Script goes here
	 
$("div.result").hide();
	 

$("form").submit(function() {
	
	var dataString = 'login='+ $("input[name=login]").val();
	var url = $(this).attr("action");
	
	
	$('input:not([type=submit]), textarea', this).each(function(index) {
		dataString += "&"+$(this).attr("name")+"="+$(this).val();
	});
	
	
	var result = $(this).next("div.result").show().html("Odesilani pozadavku....");
	
	$.ajax({  
		  type: "POST",  
		  url: url,  
		  data: dataString,  
		  success: function(data) {  
			  result.html(data);
		  }
		});
	
	
	return false;
  });
	 
}); 

</script>




</body>
</html>